﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ButtonOrderParse : UIOrderParse
{
    public ButtonOrderParse(BasePanel panel):base(panel)
    {

    }

    //以下是命令对应的调用方法

    //显示新的ui面板
    public void Goto(BaseUIElement uiElement)
    {
        Button button = uiElement.GetComponent<Button>();
        button.onClick.RemoveAllListeners();
        button.onClick.AddListener(() => {
            panel.uiManager.ShowPanel(this.parameters[0].ToString());
        });
    }

    //关闭当前面板
    public void Exit(BaseUIElement uiElement)
    {
        Button button = uiElement.GetComponent<Button>();
        button.onClick.RemoveAllListeners();
        button.onClick.AddListener(() => {
            panel.uiManager.HideCurrentPanel();
        });
    }

    //传递参数
    public void Param(BaseUIElement uiElement)
    {
        uiElement.SetParameters(this.parameters);
    }
}
